package main;

/**
 *
 * @author MISTIC 
 */
import java.io.*;
import javax.security.auth.callback.*;

public class MyCallbackHandler implements CallbackHandler {
	private String usuario;
	private String password;

	@Override
	public void handle(Callback[] callbacks) throws IOException,
			UnsupportedCallbackException {
		for (Callback cb : callbacks) {
			if (cb instanceof NameCallback) {
				// The user can provide this information using the console or a
				// GUI.
				((NameCallback) cb).setName(usuario); // The user can provide
														// this information
														// using the console or
														// a GUI.
			} else if (cb instanceof PasswordCallback) {
				// The user can provide this information using the console or a
				// GUI.
				((PasswordCallback) cb).setPassword(password.toCharArray());
			} else if (cb instanceof TextOutputCallback) {
				System.out.println(((TextOutputCallback) cb).getMessage());
			}
		}
	}
	public String getUsuario() {
		return usuario;
	}
	public void setUsuario(String usuario) {
		this.usuario = usuario;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}
